package org.ms.springcloud.ribbon.consumer;

import org.ms.springcloud.service.api.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

@RestController
public class RestTemplateController {

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/findUserById/{id}")
    public User findUserById(@PathVariable("id") Long id) {
        User user = this.restTemplate.getForObject("http://spring-cloud-eureka-client/user/" + id, User.class);
        System.out.println("User: " + user.toString());
        return user;
    }

}